#include "songitem.h"
#include <iostream>
#include <iomanip>
#include <sstream>
#include "pattern.h"
using namespace std;

SongItem::SongItem(Pattern *pPattern, int number)
: m_pPattern(pPattern), m_number(number) {
}

SongItem::~SongItem() {
}

Pattern *SongItem::pattern() {
     return m_pPattern;
}

void SongItem::setPattern(Pattern *pPattern) {
     m_pPattern = pPattern;
}

int SongItem::number() {
     return m_number;
}

void SongItem::setNumber(int number) {
     m_number = number;
}

string SongItem::toString() {
     ostringstream s;
     s << numStr() << nameStr();
     return s.str();
}

string SongItem::numStr() {
     if (!m_pPattern)
	  return "..";
     ostringstream s;
     s << hex << uppercase << setw(2) << setfill('0') << m_pPattern->number();
     return s.str();
}

string SongItem::nameStr() {
     if (!m_pPattern)
	  return "";
     return m_pPattern->name().substr(0,8);
}
